//Copyright (c) 2010, Information Security Institute of Wuhan Universtiy(ISIWhu)
//All rights reserved.
//
//PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM
//BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF
//THIS LICENSE.  IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO
//NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER.
//
//This License allows you to:
//1. Make copies and distribute copies of the Program's source code provide that any such copy 
//   clearly displays any and all appropriate copyright notices and disclaimer of warranty as set 
//   forth in this License.
//2. Modify the original copy or copies of the Program or any portion thereof ("Modification(s)"). 
//   Modifications may be copied and distributed under the terms and conditions as set forth above. 
//   Any and all modified files must be affixed with prominent notices that you have changed the 
//   files and the date that the changes occurred.

//Termination:
//   If at anytime you are unable to comply with any portion of this License you must immediately 
//   cease use of the Program and all distribution activities involving the Program or any portion 
//   thereof.

//Statement:
//   In this program, part of the code is from the GTNetS project, The Georgia Tech Network 
//   Simulator (GTNetS) is a full-featured network simulation environment that allows researchers in 
//   computer networks to study the behavior of moderate to large scale networks, under a variety of 
//   conditions. Our work have great advance due to this project, Thanks to Dr. George F. Riley from 
//   Georgia Tech Research Corporation. Anyone who wants to study the GTNetS can come to its homepage:
//   http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/
//


//File Information:
//
//
//File Name:
//File Purpose:
//Original Author:
//Author Organization:
//Construct Data:
//Modify Author:
//Author Organization:
//Modify Data:



// Georgia Tech Network Simulator - Base class for mobility models
// George F. Riley.  Georgia Tech, Spring 2002

// Define the base class for all mobility models

#ifndef __mobililty_h__
#define __mobililty_h__

#include <list>

#include "simulator.h"

class Node;
class Location;

//Doc:ClassXRef
class Waypoint {
public:
  Waypoint() : time(0) {}
  Waypoint(Time_t t, Meters_t x, Meters_t y, Meters_t z=0)
    : time(t), location(x,y,z) {}
  Waypoint(Time_t t, const Location& l) : time(t), location(l) {}
public:
  Time_t   time;     // Time to arrive at specified location
  Location location; // Location
};

typedef std::list<Waypoint>      WaypointList_t;
typedef WaypointList_t::iterator WaypointIt_t;


//Doc:ClassXRef
class Mobility {
public:
  Mobility() : lastTime(Simulator::Now()), velocityX(0), velocityY(0),
               velocityZ(0) {}
  Mobility(const Mobility&);               // Copy constructor
public:
  virtual void UpdateLocation(Node*) = 0;  // Compute new location
  virtual Mobility* Copy() const = 0;      // Make a copy
  virtual void Initialize() = 0;           // Initialize the mobility
  virtual bool IsMoving() const;           // True if currently moving
  virtual Angle_t Direction() const;       // Angle of motion
protected:
  void ComputeVelocities(Location&, Location&, Meters_t); // Compute x/y/z vel.
  void Move(Node*, Time_t);         // Move for t seconds at current velocities
  static Meters_t Distance(Location&, Location&); // Compute distance
  Time_t        lastTime;    // Time last updated
  Meters_t      velocityX;
  Meters_t      velocityY;
  Meters_t      velocityZ;
  // Moved from subclasses, GFR May 11, 2004
  bool            paused;
  bool            first;       // First entry to UpdateLocation
  Waypoint        lastWP;      // Waypoint of previous location
  Waypoint        nextWP;      // Waypoint moving to
};

#endif
